package com.amentretenimiento;

import java.util.ArrayList;
import java.util.Dictionary;

import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import android.content.Context;
import android.util.Log;



public class Utilities {

	public static boolean isNetwork(){
		boolean bool = false;
		HttpGet requestForTest = new HttpGet("http://m.google.com");
		try {
			new DefaultHttpClient().execute(requestForTest); // can last...
			bool = true;
		} catch (Exception e) {
		}
		return bool;
	}
	
	
	public  static ArrayList<Dictionary<String, String>> qry (Context ctx, String strCadena){
		ArrayList<Dictionary<String, String>> Resultados = null;
    	String URL = ctx.getString(R.string.QRY_URL) + strCadena;
		Log.i("URL", ""+URL);
		saxXML saxparser = new saxXML(URL);
		
		
		try {
			Resultados = saxparser.parse(0);
//			Log.i("URL","" + URL);
		} catch (Exception e) {
			
		}
		return Resultados;
	}
	
	public  static ArrayList<Dictionary<String, String>> qry2 (Context ctx, String strCadena){
		ArrayList<Dictionary<String, String>> Resultados = null;
    	String URL = ctx.getString(R.string.QRY_URL1) + strCadena;
		Log.i("URL", ""+URL);
		saxXML saxparser = new saxXML(URL);
		
		
		try {
			Resultados = saxparser.parse(1);
//			Log.i("URL","" + URL);
		} catch (Exception e) {
			
		}
		return Resultados;
	}
	
	
	public  static ArrayList<Dictionary<String, String>> qry3 (Context ctx, String strCadena){
		ArrayList<Dictionary<String, String>> Resultados = null;
    	String URL = ctx.getString(R.string.QRY_URL2) + strCadena;
		Log.i("URL", ""+URL);
		saxXML saxparser = new saxXML(URL);
		
		
		try {
			Resultados = saxparser.parse(2);
//			Log.i("URL","" + URL);
		} catch (Exception e) {
			
		}
		return Resultados;
	}


}
